package com.admin.dao;

import com.admin.entity.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminDao {

    //管理员登录
    @Select("select * from admin where adminName = #{adminName} and passWord = #{passWord}")
    List<Admin> selectUser(Admin admin);

    //用户显示
    @Select("select * from user")
    List<User> userShow();

    //用户删除
    @Delete("delete from user where id = #{id}")
    int deleteUser(@Param("id")int id);

    //订单显示
    @Select("select * from `order`")
    List<Order> orderShow();

    //订单删除
    @Delete("delete from `order` where id = #{id}")
    int deleteOrder(@Param("id")int id);

    //库存显示
    @Select("select repository.id,product.name,repository.sum " +
            "from repostory,peoduct " +
            "where repository.product_id=product.id")
    List<RepositoryFinal> repositorySelect();


    //库存修改
    @Update("update repository set sum = #{sum} where id = #{id}")
    int repertoryUpdate(Repository repository);

    //产品显示
    @Select("select * from product")
    List<Product> productSelect();

    //产品删除
    @Delete("delete from product where id = #{id}")
    int productDelete(@Param("id") int id);

    //产品上架
    @Insert("insert into product values(#{id},#{name},#{describe},#{url},#{price})")
    int productInsert(ProductFinal productFinal);

    //上架后添加库存量
    @Insert("insert into repertory(product_id,sum) values(#{id},#{sum})")
    int repertoryAdd(ProductFinal productFinal);
}
